<template>
  <div class="image-annotation-viewer">
    <!-- 顶部工具栏 -->
    <div class="viewer-toolbar">
      <el-button
        type="primary"
        @click="openFullscreenPreview"
      >
        <el-icon><FullScreen /></el-icon>
        全屏预览
      </el-button>

      <div class="viewer-info">
        <span>标注点数量: {{ annotations.length }}</span>
      </div>
    </div>

    <!-- 图片显示区域 -->
    <div 
      v-if="hasBackgroundImage" 
      class="viewer-container" 
      ref="viewerContainer"
      @click="closeDetailDialog"
    >
      <div class="image-wrapper" :style="imageWrapperStyle">
        <img 
          :src="backgroundImage.url" 
          :style="imageStyle"
          @load="handleImageLoad"
          ref="viewerImg"
          alt="底图"
        />
        
        <!-- 标注点 -->
        <AnnotationPoint
          v-for="annotation in annotations"
          :key="annotation.id"
          :annotation="annotation"
          :is-preview="true"
          :container-width="containerWidth"
          :container-height="containerHeight"
          @click="showAnnotationDetail"
        />
      </div>
    </div>

    <!-- 无数据提示 -->
    <div v-else class="no-data">
      <el-empty description="暂无底图数据">
        <el-button type="primary" @click="$emit('edit')">
          去编辑模式添加底图
        </el-button>
      </el-empty>
    </div>

    <!-- PC端标注点详情对话框 -->
    <el-dialog
      v-if="!isMobileDevice && showDetailDialog"
      v-model="showDetailDialog"
      :title="currentAnnotation?.title || '标注详情'"
      width="500px"
      :append-to-body="true"
      :close-on-click-modal="true"
    >
      <div v-if="currentAnnotation" class="annotation-detail pc-detail">
        <div class="detail-header">
          <el-icon class="detail-icon"><Location /></el-icon>
          <h3>{{ currentAnnotation.title }}</h3>
        </div>

        <div class="detail-content">
          <div class="detail-section">
            <h4>详细描述</h4>
            <p class="description-text">
              {{ currentAnnotation.description || '暂无描述信息' }}
            </p>
          </div>

          <div class="detail-section">
            <h4>位置信息</h4>
            <div class="position-info">
              <el-tag type="primary" size="large">
                <el-icon><Position /></el-icon>
                X: {{ currentAnnotation.left }}%
              </el-tag>
              <el-tag type="success" size="large">
                <el-icon><Position /></el-icon>
                Y: {{ currentAnnotation.top }}%
              </el-tag>
            </div>
          </div>
        </div>
      </div>
    </el-dialog>

    <!-- 移动端标注点详情抽屉 -->
    <el-drawer
      v-if="isMobileDevice && showDetailDialog"
      v-model="showDetailDialog"
      :title="currentAnnotation?.title || '标注详情'"
      direction="btt"
      size="60%"
      :close-on-click-modal="true"
    >
      <div v-if="currentAnnotation" class="annotation-detail mobile-detail">
        <div class="mobile-detail-header">
          <div class="mobile-icon">
            <el-icon><Location /></el-icon>
          </div>
          <div class="mobile-title">
            <h2>{{ currentAnnotation.title }}</h2>
            <div class="mobile-position">
              <el-tag size="small">X: {{ currentAnnotation.left }}%</el-tag>
              <el-tag size="small">Y: {{ currentAnnotation.top }}%</el-tag>
            </div>
          </div>
        </div>

        <div class="mobile-detail-content">
          <h3>详细描述</h3>
          <p class="mobile-description">
            {{ currentAnnotation.description || '暂无描述信息' }}
          </p>
        </div>

        <div class="mobile-actions">
          <el-button
            type="primary"
            size="large"
            @click="showDetailDialog = false"
            style="width: 100%"
          >
            关闭
          </el-button>
        </div>
      </div>
    </el-drawer>

    <!-- 标注点列表侧边栏 -->
    <el-drawer
      v-model="showSidebar"
      title="标注点列表"
      direction="rtl"
      size="300px"
    >
      <div class="sidebar-content drawer-scrollbar">
        <div 
          v-for="annotation in annotations" 
          :key="annotation.id"
          class="annotation-item"
          @click="showAnnotationDetail(annotation)"
        >
          <div class="item-title">{{ annotation.title }}</div>
          <div class="item-description">{{ annotation.description || '暂无描述' }}</div>
          <div class="item-position">位置: {{ annotation.left }}%, {{ annotation.top }}%</div>
        </div>
        <el-empty v-if="annotations.length === 0" description="暂无标注点" />
      </div>
    </el-drawer>

    <!-- 浮动按钮 -->
    <div class="floating-buttons">
      <el-button
        type="primary"
        :icon="List"
        circle
        @click="showSidebar = true"
        title="标注点列表"
      />
    </div>

    <!-- 全屏预览弹窗 -->
    <el-dialog
      v-model="showFullscreenPreview"
      title=""
      width="100%"
      :show-close="false"
      :close-on-click-modal="false"
      :close-on-press-escape="true"
      fullscreen
      class="fullscreen-preview-dialog"
    >
      <div class="preview-container">
        <!-- 预览工具栏 -->
        <div class="preview-toolbar">
          <div class="toolbar-left">
            <h2>景点标注预览</h2>
            <span class="annotation-count">{{ annotations.length }} 个标注点</span>
          </div>

          <div class="toolbar-center">
            <!-- 设备切换按钮 -->
            <el-radio-group v-model="previewMode" size="large">
              <el-radio-button label="pc">
                <el-icon><Monitor /></el-icon>
                PC端
              </el-radio-button>
              <el-radio-button label="mobile">
                <el-icon><Iphone /></el-icon>
                移动端
              </el-radio-button>
            </el-radio-group>
          </div>

          <div class="toolbar-right">
            <el-button
              type="danger"
              @click="closeFullscreenPreview"
            >
              <el-icon><CloseBold /></el-icon>
              关闭预览
            </el-button>
          </div>
        </div>

        <!-- 设备框架预览区域 -->
        <div class="device-preview-area">
          <!-- PC设备框架 -->
          <div v-if="previewMode === 'pc'" class="device-frame pc-frame">
            <div class="pc-screen">
              <div class="pc-browser-bar">
                <div class="browser-controls">
                  <span class="control-dot red"></span>
                  <span class="control-dot yellow"></span>
                  <span class="control-dot green"></span>
                </div>
                <div class="address-bar">
                  <span>https://景点标注系统.com</span>
                </div>
              </div>
              <div class="pc-content" ref="pcPreviewContainer">
                <div class="preview-image-wrapper" :style="pcImageWrapperStyle">
                  <img
                    :src="backgroundImage.url"
                    :style="previewImageStyle"
                    @load="handlePreviewImageLoad"
                    ref="pcPreviewImg"
                    alt="预览图片"
                  />

                  <!-- PC端标注点 -->
                  <AnnotationPoint
                    v-for="annotation in annotations"
                    :key="`pc-${annotation.id}`"
                    :annotation="annotation"
                    :is-preview="true"
                    :container-width="pcContainerWidth"
                    :container-height="pcContainerHeight"
                    @click="showPreviewAnnotationDetail"
                  />
                </div>
              </div>
            </div>
          </div>

          <!-- 移动设备框架 -->
          <div v-else class="device-frame mobile-frame">
            <div class="mobile-screen">
              <div class="mobile-status-bar">
                <span class="time">9:41</span>
                <div class="status-icons">
                  <span class="signal">●●●</span>
                  <span class="wifi">📶</span>
                  <span class="battery">🔋</span>
                </div>
              </div>
              <div class="mobile-content" ref="mobilePreviewContainer">
                <div class="preview-image-wrapper" :style="mobileImageWrapperStyle">
                  <img
                    :src="backgroundImage.url"
                    :style="previewImageStyle"
                    @load="handlePreviewImageLoad"
                    ref="mobilePreviewImg"
                    alt="预览图片"
                  />

                  <!-- 移动端标注点 -->
                  <AnnotationPoint
                    v-for="annotation in annotations"
                    :key="`mobile-${annotation.id}`"
                    :annotation="annotation"
                    :is-preview="true"
                    :container-width="mobileContainerWidth"
                    :container-height="mobileContainerHeight"
                    @click="showPreviewAnnotationDetail"
                  />
                </div>
              </div>
              <div class="mobile-home-indicator"></div>
            </div>
          </div>
        </div>
      </div>

      <!-- 预览模式下的标注详情 -->
      <el-dialog
        v-model="showPreviewDetailDialog"
        :title="currentPreviewAnnotation?.title || '标注详情'"
        width="500px"
        :append-to-body="true"
        :close-on-click-modal="true"
      >
        <div v-if="currentPreviewAnnotation" class="annotation-detail">
          <div class="detail-header">
            <el-icon class="detail-icon"><Location /></el-icon>
            <h3>{{ currentPreviewAnnotation.title }}</h3>
          </div>

          <div class="detail-content">
            <div class="detail-section">
              <h4>详细描述</h4>
              <p class="description-text">
                {{ currentPreviewAnnotation.description || '暂无描述信息' }}
              </p>
            </div>

            <div class="detail-section">
              <h4>位置信息</h4>
              <div class="position-info">
                <el-tag type="primary" size="large">
                  <el-icon><Position /></el-icon>
                  X: {{ currentPreviewAnnotation.left }}%
                </el-tag>
                <el-tag type="success" size="large">
                  <el-icon><Position /></el-icon>
                  Y: {{ currentPreviewAnnotation.top }}%
                </el-tag>
              </div>
            </div>
          </div>
        </div>
      </el-dialog>
    </el-dialog>
  </div>
</template>

<script>
import { mapState, mapGetters, mapActions } from 'vuex'
import { Edit, List, CloseBold, FullScreen, Location, Position, Monitor, Iphone } from '@element-plus/icons-vue'
import AnnotationPoint from './AnnotationPoint.vue'

export default {
  name: 'ImageAnnotationViewer',
  components: {
    AnnotationPoint,
    Edit,
    List,
    CloseBold,
    FullScreen,
    Location,
    Position,
    Monitor,
    Iphone
  },
  data() {
    return {
      showDetailDialog: false,
      showSidebar: false,
      currentAnnotation: null,
      isFullscreen: false,
      containerWidth: 800,
      containerHeight: 600,
      viewportWidth: window.innerWidth,
      viewportHeight: window.innerHeight,
      isMobile: false,
      touchStartTime: 0,
      longPressTimer: null,
      resizeTimer: null, // 防抖定时器

      // 全屏预览相关
      showFullscreenPreview: false,
      previewMode: 'pc', // 'pc' 或 'mobile'
      showPreviewDetailDialog: false,
      currentPreviewAnnotation: null,
      pcContainerWidth: 800,
      pcContainerHeight: 600,
      mobileContainerWidth: 375,
      mobileContainerHeight: 667
    }
  },
  computed: {
    ...mapState(['backgroundImage', 'annotations']),
    ...mapGetters(['hasBackgroundImage']),

    // 检测是否为移动设备
    isMobileDevice() {
      const isMobileUA = /Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
      const isSmallScreen = this.viewportWidth <= 768
      return isMobileUA || isSmallScreen
    },
    
    imageWrapperStyle() {
      if (!this.hasBackgroundImage) return {}
      
      const maxWidth = this.isFullscreen ? this.viewportWidth - 40 : this.viewportWidth - 80
      const maxHeight = this.isFullscreen ? this.viewportHeight - 100 : this.viewportHeight - 200
      
      const imageRatio = this.backgroundImage.width / this.backgroundImage.height
      const containerRatio = maxWidth / maxHeight
      
      let width, height
      
      if (imageRatio > containerRatio) {
        // 图片更宽，以宽度为准
        width = maxWidth
        height = maxWidth / imageRatio
      } else {
        // 图片更高，以高度为准
        height = maxHeight
        width = maxHeight * imageRatio
      }
      
      return {
        width: `${width}px`,
        height: `${height}px`,
        position: 'relative'
      }
    },
    
    imageStyle() {
      return {
        width: '100%',
        height: '100%',
        objectFit: 'contain',
        display: 'block'
      }
    },

    // 预览模式下的图片样式
    previewImageStyle() {
      return {
        width: '100%',
        height: '100%',
        objectFit: 'contain',
        display: 'block'
      }
    },

    // PC端预览图片包装器样式
    pcImageWrapperStyle() {
      if (!this.hasBackgroundImage) return {}

      const maxWidth = 800
      const maxHeight = 500

      const imageRatio = this.backgroundImage.width / this.backgroundImage.height
      const containerRatio = maxWidth / maxHeight

      let width, height

      if (imageRatio > containerRatio) {
        width = maxWidth
        height = maxWidth / imageRatio
      } else {
        height = maxHeight
        width = maxHeight * imageRatio
      }

      return {
        width: `${width}px`,
        height: `${height}px`,
        position: 'relative'
      }
    },

    // 移动端预览图片包装器样式
    mobileImageWrapperStyle() {
      if (!this.hasBackgroundImage) return {}

      const maxWidth = 335 // 移动端屏幕宽度减去边距
      const maxHeight = 500

      const imageRatio = this.backgroundImage.width / this.backgroundImage.height
      const containerRatio = maxWidth / maxHeight

      let width, height

      if (imageRatio > containerRatio) {
        width = maxWidth
        height = maxWidth / imageRatio
      } else {
        height = maxHeight
        width = maxHeight * imageRatio
      }

      return {
        width: `${width}px`,
        height: `${height}px`,
        position: 'relative'
      }
    }
  },
  mounted() {
    this.loadFromLocal()
    window.addEventListener('resize', this.handleResize)
    document.addEventListener('visibilitychange', this.handleVisibilityChange)
    this.handleResize()
    this.detectMobile()
  },
  beforeUnmount() {
    // 清理事件监听器
    window.removeEventListener('resize', this.handleResize)
    document.removeEventListener('visibilitychange', this.handleVisibilityChange)

    // 清理定时器
    if (this.resizeTimer) {
      clearTimeout(this.resizeTimer)
      this.resizeTimer = null
    }
  },
  methods: {
    ...mapActions(['loadFromLocal']),
    
    // 处理窗口大小变化（防抖处理）
    handleResize() {
      // 清除之前的定时器
      if (this.resizeTimer) {
        clearTimeout(this.resizeTimer)
      }

      // 使用防抖处理，避免频繁更新
      this.resizeTimer = setTimeout(() => {
        this.viewportWidth = window.innerWidth
        this.viewportHeight = window.innerHeight
        this.$nextTick(() => {
          this.updateContainerSize()
        })
        this.resizeTimer = null
      }, 100)
    },

    // 处理页面可见性变化
    handleVisibilityChange() {
      if (document.hidden) {
        // 页面隐藏时，暂停不必要的操作
        if (this.resizeTimer) {
          clearTimeout(this.resizeTimer)
          this.resizeTimer = null
        }
      } else {
        // 页面显示时，重新检测设备和更新尺寸
        this.detectMobile()
        this.$nextTick(() => {
          this.updateContainerSize()
        })
      }
    },
    
    // 图片加载完成
    handleImageLoad() {
      this.updateContainerSize()
    },
    
    // 更新容器尺寸
    updateContainerSize() {
      if (this.$refs.viewerImg) {
        const img = this.$refs.viewerImg
        this.containerWidth = img.clientWidth
        this.containerHeight = img.clientHeight
      }
    },
    
    // 检测移动设备
    detectMobile() {
      this.isMobile = this.isMobileDevice
    },

    // 显示标注点详情
    showAnnotationDetail(annotation, event) {
      if (event) {
        event.stopPropagation()
      }
      this.currentAnnotation = annotation
      this.showDetailDialog = true
      this.showSidebar = false

      // 移动端振动反馈
      if (this.isMobileDevice && navigator.vibrate) {
        navigator.vibrate(50)
      }
    },
    
    // 关闭详情对话框
    closeDetailDialog() {
      // 点击空白区域关闭对话框的逻辑可以在这里实现
    },
    
    // 切换全屏模式
    toggleFullscreen() {
      this.isFullscreen = !this.isFullscreen

      if (this.isFullscreen) {
        // 进入全屏
        if (document.documentElement.requestFullscreen) {
          document.documentElement.requestFullscreen()
        }
      } else {
        // 退出全屏
        if (document.exitFullscreen) {
          document.exitFullscreen()
        }
      }

      this.$nextTick(() => {
        this.handleResize()
      })
    },

    // 打开全屏预览
    openFullscreenPreview() {
      if (!this.hasBackgroundImage) {
        this.$message.warning('请先上传底图')
        return
      }
      this.showFullscreenPreview = true
      this.$nextTick(() => {
        this.updatePreviewContainerSize()
      })
    },

    // 关闭全屏预览
    closeFullscreenPreview() {
      this.showFullscreenPreview = false
      this.showPreviewDetailDialog = false
      this.currentPreviewAnnotation = null
    },

    // 预览图片加载完成
    handlePreviewImageLoad() {
      this.updatePreviewContainerSize()
    },

    // 更新预览容器尺寸
    updatePreviewContainerSize() {
      this.$nextTick(() => {
        if (this.previewMode === 'pc' && this.$refs.pcPreviewImg) {
          const img = this.$refs.pcPreviewImg
          this.pcContainerWidth = img.clientWidth
          this.pcContainerHeight = img.clientHeight
        } else if (this.previewMode === 'mobile' && this.$refs.mobilePreviewImg) {
          const img = this.$refs.mobilePreviewImg
          this.mobileContainerWidth = img.clientWidth
          this.mobileContainerHeight = img.clientHeight
        }
      })
    },

    // 显示预览模式下的标注详情
    showPreviewAnnotationDetail(annotation, event) {
      if (event) {
        event.stopPropagation()
      }
      this.currentPreviewAnnotation = annotation
      this.showPreviewDetailDialog = true
    }
  }
}
</script>

<style scoped>
.image-annotation-viewer {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #f0f2f5;
  position: relative;
}

.image-annotation-viewer.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  background: #000;
}

.viewer-toolbar {
  padding: 20px 24px;
  background: white;
  border-bottom: 1px solid #e4e7ed;
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.viewer-info {
  margin-left: auto;
  color: #606266;
  font-size: 14px;
}

.viewer-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  padding: 24px;
  overflow: auto;
}

.fullscreen .viewer-container {
  min-height: calc(100vh - 80px);
  background: #000;
}

.image-wrapper {
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  overflow: hidden;
}

.fullscreen .image-wrapper {
  box-shadow: none;
  border-radius: 0;
}

.no-data {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 400px;
}

/* PC端详情样式 */
.pc-detail {
  padding: 0;
}

.detail-header {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e4e7ed;
}

.detail-icon {
  font-size: 24px;
  color: #409eff;
  margin-right: 10px;
}

.detail-header h3 {
  margin: 0;
  color: #303133;
  font-size: 20px;
  font-weight: 600;
}

.detail-content {
  padding: 0;
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section h4 {
  margin: 0 0 10px 0;
  color: #409eff;
  font-size: 14px;
  font-weight: 600;
}

.description-text {
  margin: 0;
  color: #606266;
  line-height: 1.6;
  font-size: 14px;
  background: #f8f9fa;
  padding: 15px;
  border-radius: 6px;
  border-left: 3px solid #409eff;
}

.position-info {
  display: flex;
  gap: 10px;
}

.position-info .el-tag {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  font-size: 13px;
}

/* 移动端详情样式 */
.mobile-detail {
  padding: 0;
}

.mobile-detail-header {
  display: flex;
  align-items: flex-start;
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e4e7ed;
}

.mobile-icon {
  width: 50px;
  height: 50px;
  background: #409eff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 15px;
  flex-shrink: 0;
}

.mobile-icon .el-icon {
  font-size: 24px;
  color: white;
}

.mobile-title {
  flex: 1;
}

.mobile-title h2 {
  margin: 0 0 8px 0;
  color: #303133;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.3;
}

.mobile-position {
  display: flex;
  gap: 8px;
}

.mobile-detail-content {
  margin-bottom: 30px;
}

.mobile-detail-content h3 {
  margin: 0 0 15px 0;
  color: #409eff;
  font-size: 16px;
  font-weight: 600;
}

.mobile-description {
  margin: 0;
  color: #606266;
  line-height: 1.7;
  font-size: 16px;
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  border-left: 4px solid #409eff;
}

.mobile-actions {
  padding-top: 20px;
  border-top: 1px solid #e4e7ed;
}

.sidebar-content {
  padding: 10px;
}

.annotation-item {
  padding: 15px;
  border: 1px solid #e4e7ed;
  border-radius: 8px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.annotation-item:hover {
  border-color: #409eff;
  background: #f0f9ff;
}

.item-title {
  font-weight: bold;
  color: #303133;
  margin-bottom: 5px;
}

.item-description {
  color: #606266;
  font-size: 12px;
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-position {
  color: #909399;
  font-size: 11px;
}

.floating-buttons {
  position: fixed;
  right: 30px;
  bottom: 30px;
  z-index: 1000;
}

/* 全屏预览样式 */
.fullscreen-preview-dialog {
  background: #000;
}

.fullscreen-preview-dialog .el-dialog__body {
  padding: 0;
  height: 100vh;
}

.preview-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #000;
  color: white;
}

.preview-toolbar {
  background: rgba(0, 0, 0, 0.9);
  padding: 15px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  z-index: 10;
}

.toolbar-left h2 {
  margin: 0 15px 0 0;
  font-size: 24px;
  font-weight: 600;
  color: white;
}

.annotation-count {
  color: #909399;
  font-size: 14px;
}

.toolbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.toolbar-right {
  display: flex;
  gap: 10px;
}

.device-preview-area {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
  overflow: auto;
}

/* PC设备框架 */
.pc-frame {
  background: #2c3e50;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.pc-screen {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.pc-browser-bar {
  background: #f5f5f5;
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 15px;
  border-bottom: 1px solid #e0e0e0;
}

.browser-controls {
  display: flex;
  gap: 8px;
  margin-right: 15px;
}

.control-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.control-dot.red {
  background: #ff5f57;
}

.control-dot.yellow {
  background: #ffbd2e;
}

.control-dot.green {
  background: #28ca42;
}

.address-bar {
  flex: 1;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  color: #666;
}

.pc-content {
  background: #f8f9fa;
  min-height: 500px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* 移动设备框架 */
.mobile-frame {
  background: #1a1a1a;
  border-radius: 30px;
  padding: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.mobile-screen {
  background: white;
  border-radius: 22px;
  overflow: hidden;
  width: 375px;
  height: 667px;
  position: relative;
}

.mobile-status-bar {
  background: #000;
  color: white;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 600;
}

.status-icons {
  display: flex;
  gap: 5px;
  font-size: 12px;
}

.mobile-content {
  background: #f8f9fa;
  height: calc(100% - 44px - 34px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.mobile-home-indicator {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 134px;
  height: 5px;
  background: #000;
  border-radius: 3px;
}

/* 预览图片包装器 */
.preview-image-wrapper {
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.floating-buttons .el-button {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .viewer-toolbar {
    padding: 10px 15px;
    flex-direction: column;
    align-items: stretch;
  }
  
  .viewer-toolbar .el-button {
    width: 100%;
    margin-bottom: 5px;
  }
  
  .viewer-info {
    margin-left: 0;
    text-align: center;
  }
  
  .viewer-container {
    padding: 10px;
  }
  
  .floating-buttons {
    right: 15px;
    bottom: 15px;
  }
}
</style>
